package org.infodavid.common.util;

/**
 * The Interface IVisitor.
 * @param <I> the element type
 * @param <O> the element type
 */
public interface IVisitor<I,O> {

	/**
	 * The Interface IResult.
	 */
	interface IResult<O> {

		/**
		 * Gets the data.
		 * @return the data
		 */
		O getData();

		/**
		 * Checks if is successful.
		 * @return true, if is successful
		 */
		boolean isSuccessful();
	}

	@SuppressWarnings("rawtypes")
	IResult SUCCESS = new IResult() {
		public Object getData() {
			return null;
		}

		public boolean isSuccessful() {
			return true;
		}
	};

	@SuppressWarnings("rawtypes")
	IResult FAILURE = new IResult() {
		public Object getData() {
			return null;
		}

		public boolean isSuccessful() {
			return false;
		}
	};
	
	/**
	 * Initialize.
	 * @throws Throwable the error
	 */
	void initialize() throws Exception;

	/**
	 * Visit.
	 * @param data the data
	 * @return true, if successful
	 * @throws Throwable the error
	 */
	IResult<O> visit(I data) throws Exception;
}
